package com.foreknow.oop.hw1;

public class Point {
    private int x;
    private int y;

    public Point() {
        this.x = 10;
        this.y = 10;
    }

    public Point(int x0, int y0) {
        this.x = x0;
        this.y = y0;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    /**
     * 移动点
     *
     * @param dx 向x方向移动的距离
     * @param dy 向y方向移动的距离
     */
    public void movePoint(int dx, int dy) {
        this.x += dx;
        this.y += dy;
    }

    public static void main(String[] args) {
        Point p1 = new Point();
        Point p2 = new Point(15, 15);
        p1.movePoint(20, 20);
        System.out.printf("p1的坐标为(%d,%d)\n", p1.getX(), p1.getY());
        p2.movePoint(25, 25);
        System.out.printf("p2的坐标为(%d,%d)\n", p2.getX(), p2.getY());
    }
}
